LCD INTERFACING WITH ARDUINO
In this tutorial we are going to interface a 16x2 LCD with ARDUINO UNO. Compared to other controllers, Interfacing LCD with Arduino is very easy. In other microcontrollers, one should write the complete code for the working of LCD whereas Arduino provides a very good platform for non-programmers. Let us see the interfacing clearly.
Synopsis

To establish a good communication between human world and machine world, display units play an important role. And so they are an important part of embedded systems. Many electronic displays are used in embedded system such as 7 Segment, LED displays but they have their own limitations. Liquid Crystal Displays are used in many devices like micro oven, calculators etc.

In this tutorial we are going to interface a 16x2 LCD with ARDUINO UNO. Compared to other controllers, Interfacing LCD with Arduino is very easy. In other microcontrollers, one should write the complete code for the working of LCD whereas Arduino provides a very good platform for non-programmers. Let us see the interfacing clearly.

Here also we are using the ATmega328p AVR 8-bit microcontroller to develop an Arduino board. The Atmel ATmega328p is a low power CMOS 8-bit controller based on the AVR enhanced RISC architecture.

Description

16X2 LCD is the most commonly used LCD Display.16X2 indicates that it can display 32 characters in 2 lines. It has 16 pins. They are shown below.


Pin Description

Data Pins: Pin7 to Pin14 are data Pins.

VSS: It is the Ground Pin of the module.

VDD: It is the supply pin of the module.

VEE: Pin3 is used for controlling the brightness of the LCD. Normal setting of this pin is between 0.4V to 0.9V.A 10 k pot is connected to adjust the brightness of the screen.

Register Select: RS pin is used to select the register. There are two registers in this LCD. They are data register data   instruction register. Data register sends data to the screen while instruction register sends Commands to LCD’s controller, which controls the instructions.

Logic High (1) – Activates Data register.

Logic Low (0) – Activates Instruction register.

RW selects either read or write mode. In this pin is connected to ground.

Logic High (1) – Activates Read mode.

Logic Low (0) – Activates Write mode.

Enable: E enables the LCD module.

LCD can be used either in 4-bit mode or 8-bit mode. In 4-bit mode it requires 7 IO pins of the Arduino. In 8 bit mode 11 IO pins required from Arduino.


Arduino IDE has a library which contains important functions to get this module up and running. I wanted to build a library for Atmega328p which does almost similar functions as Liquid Crystal Library in Arduino IDE.

ATmega 328p

The Atmel 8-bit AVR RISC-based microcontroller combines 32KB ISP flash memory with read-while-write capabilities, 1KB EEPROM, 2KB SRAM, 23 general purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare modes, internal and external interrupts, serial programmable USART, a byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF packages), programmable watchdog timer with internal oscillator, and five software selectable power saving modes. The device operates between 1.8 to 5.5 volts. The device achieves throughout approaching 1 MIPS per MHz.

VCC: Digital supply voltage.

RESET: If the RSTDISBL fuse is programmed, PC6 is used as an input pin. If the RSTDISBL fuse is not programmed, PC6 is used as a reset input. A low level on this pin for longer than the minimum pulse length will generate a reset.

Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2 is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability.

Depending on the clock selection fuse settings, PB6 can be used as input to the inverting oscillator amplifier and input to the internal clock operating circuit.

Depending on the clock selection fuse settings, PB7 can be used as output from the inverting oscillator amplifier.

AVCC is the supply voltage pin for the A/D converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.

Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, port D pins that are externally pulled low will source current if the pull-up resistors are activated. The port D pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Proteus design for LCD interfacing with Arduino


Orcad design for LCD interfacing with Arduino


LCD interfacing with Arduino

/*  Name     : main.c
 *  Purpose  : Source code for LCD Interfacing with ATmega328p.
 *  Author   : Gemicates
 *  Date     : 27-12-2017
 *  Website  : www.gemicates.org
 *  Revision : None
 */

#include <LiquidCrystal.h>            // this header file has instructions written in it, which enables
                                      // the user to interface an LCD to UNO in 4 bit mode without any fuzz

LiquidCrystal lcd(5,4,3,2,1,0);       // sets the interfacing pins

void setup()
{
  lcd.begin(16,2);                    // initializes the 16*2 LCD
}

void loop()
{
  lcd.setCursor(0,0);                 // sets the cursor at row 0 column 0
  lcd.print("16*2 LCD MODULE");       // prints 16*2 LCD MODULE
  lcd.setCursor(0,1);                 // sets cursor at row 0 column 1
  lcd.print("GEMICATES LABS");        // prints GEMICATES LABS
}

Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close